package com.tydic.ribbonconsumer.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: 测试熔断器
 * @Author: xuwenguang
 * @CreateDate: 2019/3/6 10:47
 * @UpdateUser: xuwenguang
 * @UpdateDate: 2019/3/6 10:47
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Service
public class HelloService {
    @Autowired
    private RestTemplate restTemplate;
    @HystrixCommand(fallbackMethod = "fallback")
    public String  hello(){
        return restTemplate.getForEntity("http://serviceprovider/hello",String.class).getBody();
    }

    public String fallback(){
        return "error";
    }
}
